<template>
  <span><el-button type="text" @click="openNewUrl" size="mini">点击查看图片</el-button></span>
</template>

<script>
  import { getURL } from '@/api/img'
  export default {
    props: {
      item: {
        type: Object,
      }
    },
    methods:{
      openNewUrl(){
        let url = this.item.info
        let lastUrl = this.item.info;
        // 最老的情况
        if(/img\[(.+)\]/g.test(url)){
          lastUrl = /img\[(.+)\]/g.exec(url)[1]
        }
        if(lastUrl.includes('net/')){
          lastUrl = lastUrl.split('net/')[1]
        }
        const key =  lastUrl.split('?')[0];
        getURL(key).then(res=>{
          const d = res.data;
          if(d.status == 0){
            window.open(d.data.urls[0].url)
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
